# 文件加载地址
setwd('C:/Users/15791/Documents/Rshijian3/ADdata')

# R包加载
library(openxlsx)
library(writexl)
library(readr)
library(readxl)
library(dplyr)

# 读取文件
txt1 <- read.table("C:/Users/15791/Downloads/ADdata/ADdata1.txt",sep="\t",header=TRUE)
txt2 <- read.csv("C:/Users/15791/Downloads/ADdata/ADdata2.csv",header=TRUE)
xlsx1 <- read_excel("C:/Users/15791/Downloads/ADdata/ADdata3.xlsx",sheet=1)
txt3 <- read.table("C:/Users/15791/Downloads/ADdata/ADdata4.txt",sep=" ",header=TRUE)

# 合并文件
res1 <- merge(txt1,txt2,by.x = 0, by.y = "X")
res2 <- merge(res1, xlsx1,by.x = "Row.names",by.y = "...1")
res3 <- merge(res2,txt3,by.x = "Row.names",by.y = 0)
all_data <- res3

# 导出文件
write.csv(all_data, "final_merged_data.csv", row.names = FALSE)
write_xlsx(all_data, "final_merged_data.xlsx")
write.table(all_data, "final_merged_data.txt")
